#ifndef PARSER_SORT_H
#define PARSER_SORT_H

#include "ParserBase.h"


/**
 * This is the handler for sort commands
 *
 @author Ling Chun Kai
*/

class ParserSort : public ParserBase {
public:
	ParserSort(ParserBase* _nextParser);
private:
	enum {INSTRUCTION_POS = 1, ARGUMENTS_POS, NUM_MAJOR_SEGMENTS};

	// The following are regex constants used for parsing
	static const string regexInstructionAndArguments;

	static const string regexInstructionSort;

	static const string regexArgumentSortAlphabet;
	static const string regexArgumentSortTime;
	static const string regexArgumentSortCompleted;
	static const string regexArgumentSortFlag;

	bool tryParse(string userCommand, PARSED_COMMAND& parsedCommand);

	bool getInstructionAndArguments(const string& userCommand, 
										string& instruction, 
										string& arguments);

	// This method checks that the instruction is of the type 'list'
	bool checkInstruction(const string& instruction);

	// This method finds out what kind of "sort" command the user entered
	CommandType categorizeSortCommand(const string& arguments, smatch& matchingArguments);

	void parseSort(PARSED_COMMAND& parsedCommand,
				  const string& arguments);

};

#endif